<?php

namespace App\Models\Station;

use App\Models\Genre;
use Illuminate\Database\Eloquent\Model;

/**
 * 岗点设置数据模型
 * 用于保存岗点的报岗时间点信息
 *
 * Date: 02/05/2018
 * @author George
 * @package App\Models\Station
 */
class Timing extends Model
{
	/**
	 * 定义不可填充字段
	 *
	 * @var array
	 * Date: 01/05/2018
	 * @author George
	 */
	protected $guarded = ['id'];

	/**
	 * 获取报岗记录
	 *
	 * Date: 04/05/2018
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
	 */
	public function reports()
	{
		return $this->hasMany(Report::class, 'timing_id', 'id');
	}

	/**
	 * 获取当天报岗记录
	 *
	 * Date: 17/05/2018
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\HasOne
	 */
	public function report()
	{
		return $this->hasOne(Report::class, 'timing_id', 'id');
	}

	/**
	 * 获取班次信息
	 *
	 * Date: 12/05/2018
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
	 */
	public function genre()
	{
		return $this->belongsTo(Genre::class, 'genre_id', 'id');
	}
}
